package CtrlLayer;
import java.util.ArrayList;
import ModelLayer.*;

public class ManagerController
{
    private ManagerContainer managerContainer;

    public ManagerController()
    {
        managerContainer = ManagerContainer.getInstance();
    }

    public void createObject(){
        if(managerContainer.findManagerById(0) == null)
            managerContainer.addManager(new Manager(0,"Mike", "asd@asd.sd", "123123123123", "DIY", "admin"));
    }

    public boolean createManager(int id, String name, String email,String phoneNumber, String department, String password){
        boolean added = false;
        if(findManager(id) == null && EmployeeContainer.getInstance().findEmployeeById(id) == null) {
            EmployeeContainer.getInstance().addEmployee(new Employee(id, name, email, phoneNumber, department, password)); 
            managerContainer.addManager(new Manager(id, name, email, phoneNumber, department, password));
            added = true;
        } else {
            added = false;
        }
        return added;
    }

    public Manager findManager(int id){    
        return  managerContainer.findManagerById(id);
    }

    public void deleteManager(int id){
        managerContainer.deleteManager(managerContainer.findManagerById(id));
    }

    public void updateManager(int id, String name, String email,String phoneNumber, String department, String password){
        Manager p =  managerContainer.findManagerById(id);
        if(p != null){
            p.setName(name);
            p.setEmail(email);
            p.setPhoneNumber(phoneNumber);
            p.setDepartment(department);
            p.setPassword(password);
        }
    }
}
